package com.sfh.gd.domain.entity;


import com.fasterxml.jackson.annotation.JsonFormat;
import com.mybatisflex.annotation.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 *  赛事实体类。
 *
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table("gd_game_pk")
public class GamePKDO implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id(keyType = KeyType.Auto)
    private Long id;
    /**
     * 赛事ID
     */
    private Long gameId;
    /**
     *状态 1-进行中  2-已结束 3-已取消
     */
    private Integer state;
    /**
     * 桌号
     */
    private String tabNo;

    /**
     * 结算积分
     */
    private Long points;
    /**
     * 比赛耗时
     */
    private Long gameTime;

    /**
     * 轮次
     */
    private Integer roundCount;
    /**
     * 胜出队伍Id
     */
    private Long winTeamId;
    /**
     * 胜方牌等级
     */
    private Long winLevel;
    /**
     * 负方牌等级
     */
    private Long loseLevel;

    /**
     * A组队伍Id
     */
    private Long teamAId;
    /**
     * A组队伍当前积分
     */
    private Long teamAPoints;
    /**
     * B组队伍Id
     */
    private Long teamBId;
    /**
     * B组队伍当前积分
     */
    private Long teamBPoints;


    /**
     * 方位东选手ID
     */
    private Long eastId;

    /**
     * 方位西选手ID
     */
    private Long westId;
    /**
     * 方位南选手ID
     */
    private Long southId;
    /**
     * 方位北选手ID
     */
    private Long northId;



    /**
     * 创建时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @Column(onUpdateValue = "LocalDateTime.now()")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private LocalDateTime updateTime;

    //队伍A
    @RelationOneToOne(selfField = "teamAId", targetField = "teamId")
    private GameTeamDO teamA;
    //队伍B
    @RelationOneToOne(selfField = "teamBId", targetField = "teamId")
    private GameTeamDO teamB;

    //方位东选手
    @RelationOneToOne(selfField = "eastId", targetField = "userId")
    private MemberDO  eastUser;
    //方位西选手
    @RelationOneToOne(selfField = "westId", targetField = "userId")
    private MemberDO  westUser;

    //方位南选手
    @RelationOneToOne(selfField = "southId", targetField = "userId")
    private MemberDO  southUser;
    //方位北选手
    @RelationOneToOne(selfField = "northId", targetField = "userId")
    private MemberDO  northUser;

}
